﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace UnitTest_MetaMapics.Pbf
{
  public static class AssertEx
  {
    public static void Throws<T>(Action func) where T : Exception
    {
      var exceptionThrown = false;
      try
      {
        func();
      }
      catch (T)
      {
        exceptionThrown = true;
      }

      if (!exceptionThrown)
      {
        throw new AssertFailedException(
            String.Format("An exception of type {0} was expected, but not thrown", typeof(T))
            );
      }
    }
  }
}
